/*
 * @Description: 区域锁定
 */
import BaseCommand from "@/core/Frame/BaseClass/BaseCommand";

class RegionLockCommand extends BaseCommand {
    viewer: any;
    globeControl: any;
    globe: any;
    constructor(params: any) {
        super();
        this.viewer = params.viewer;
        this.globeControl = this.viewer.getGlobeControl();
        this.globe = this.viewer.getGlobe();
    };

    execute(option: any) {
        let thatoption=option;
        this.globeControl.setLock(true);
        let that=this.globeControl;
        let canvas = window.owecanvas;
        canvas.addEventListener(
            'mousedown',
            function (e:any) {
                if(e.button==2)
                {
                    that.setLock(false);
                    thatoption.checked =false;
                }
            },
            {passive: false}
        );
    };
    release() {
        this.globeControl.setLock(false);
        const { globeControl } = this;
        const { PIE } = window;
        globeControl.setGlobeTool(PIE.GlobeToolType.Pan);
    };

    isEnable(option: any) {
        return true
    };
}

export default RegionLockCommand
